<template>
  <div class="comment-list">
    <div class="total">共{{ props.comment.length }}条评论</div>

    <div class="comment-item" v-for="item in props.comment" :key="item.id">
      <div>
        <div class="comment-item-header flex">
          <div class="comment-item-header-box flex">
            <img :src="item.img" alt="" />
            <div class="flex flex-column">
              <span class="span_1">{{ item.name }}</span>
              <span class="span_2">{{ item.content }}</span>
            </div>
          </div>
          <i class="iconfont icon-sandian"></i>
        </div>

        <div class="comment-item-des">
          <div class="comment-item-des-time flex">
            <span class="span_style">{{ item.day }}天前</span>
            <span class="span_style">{{ item.addressCity }}</span>
          </div>

          <div class="comment-item-des-footer flex">
            <div class="flex center">
              <i class="iconfont icon-aixin"></i>
              <span class="m_4">赞</span>
            </div>
            <div cclass="flex center">
              <i class="iconfont icon-bianzu"></i>
              <span class="m_4">回复</span>
            </div>
          </div>
        </div>
      </div>

      <!-- 子评论 -->
      <div
        class="comment-item-child"
        v-for="child in item.replyChildre"
        :key="child.id"
      >
        <div class="comment-item-header flex">
          <div class="comment-item-header-box flex">
            <img :src="child.img" alt="" />
            <div class="flex flex-column">
              <span class="span_1">{{ child.name }}</span>
              <span class="span_2">{{ child.content }}</span>
            </div>
          </div>
          <i class="iconfont icon-sandian"></i>
        </div>

        <div class="comment-item-des">
          <div class="comment-item-des-time flex">
            <span class="span_style">{{ child.day }}天前</span>
            <span class="span_style">{{ child.addressCity }}</span>
          </div>

          <div class="comment-item-des-footer flex">
            <div class="flex center">
              <i class="iconfont icon-aixin"></i>
              <span class="m_4">赞</span>
            </div>
            <div cclass="flex center">
              <i class="iconfont icon-bianzu"></i>
              <span class="m_4">回复</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { defineProps } from "vue";
const props = defineProps({
  comment: {
    type: Array,
    default: () => [],
  },
});
</script>

<style lang="scss" scoped>
.comment-list {
  .total {
    font-size: 14px;
    color: var(--color-tertiary-label);
    margin-bottom: 12px;
  }

  .comment-item {
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 8px;
    &-header {
      justify-content: space-between;

      &-box {
        img {
          width: 40px;
          height: 40px;
          border-radius: 50%;
          margin-right: 4px;
        }

        .span_1 {
          color: var(--color-tertiary-label);
          line-height: 18px;
        }
        .span_2 {
          margin-top: 4px;
          line-height: 140%;
          color: var(--color-primary-label);
        }
      }
    }

    &-des {
      margin-left: 40px;
      margin-top: 8px;
      &-time {
        font-size: 12px;
        line-height: 16px;
        color: var(--color-tertiary-label);

        .span_style {
          margin: 4px;
        }
      }
      &-footer {
        font-weight: 500;
        margin-bottom: 4px;
        div {
          margin: 4px;

          i {
            font-size: 16px;
            font-weight: 600;
          }
        }
      }
    }

    &-child {
      margin-left: 40px;
    }
  }
}
</style>